import React from 'react';
import { Drawer } from 'antd';
import { TableDrawerProps } from '../../interfaces';
import { DrawerProps } from 'antd/lib/drawer';
import '../../style.less';
import Actions from './Actions';

const TableDrawer = (props: TableDrawerProps) => {
  const { title, visible, openMode, actions, width, height, onClose, render, ...rest } = props;

  const prefixCls = 'inbiz-table-drawer';
  return (
    <div>
      <Drawer
        className={prefixCls}
        title={title}
        placement={openMode as DrawerProps['placement']}
        onClose={onClose}
        visible={visible}
        width={width}
        height={height}
        footer={<Actions actions={actions} displayQty={100} />}
        {...rest}
      >
        {render?.(props)}
      </Drawer>
    </div>
  );
};

export default React.memo(TableDrawer);
